#ifndef olcdh
#define olcdh

#include "platform.h"

void OmnimaAPISetPrintResponses(unsigned char b);
void OmnimaAPISetSerialSilenceTimeoutDefault();
void OmnimaAPISetSerialSilenceTimeout(unsigned int sMs);
void OmnimaAPISetSerialTotalTimeoutDefault();
void OmnimaAPISetSerialTotalTimeout(unsigned int tMs);

//Omnima uart synchronisation support
void WaitForSerialResponses(const termioType *pio, 
                            char **pBuff, 
                            const char *termStr,
                            unsigned int retryMs, 
                            unsigned int timeoutMs,
							unsigned char bPrintResponses);

//Base level send / receive routines
//                     
unsigned int OmnimaAPISendCmd(const termioType *pio, 
                     int waitForResp,
                     unsigned int *pRespVal,
                     const char *cmd,
                     ...);
                     
unsigned int OmnimaAPIWaitForPrompt(const termioType *pio, unsigned char bAskForPrompt);

unsigned int OmnimaAPISendCmdWithSync(const termioType *pio,  
                     int waitForResp,
                     unsigned int *pRespVal,
                     const char *cmd,
                     ...);
  
unsigned int OmnimaAPISendCmdAndGetValueResponse(const termioType *pio,
                                                 unsigned int *pResVal,
                                                const char *cmd,
                                                 ...);

unsigned int OmnimaAPIPrepareFileForUpload(const char *fileToUpload,
                                  unsigned char **ppBuff,
                                  unsigned int *pBuffLen,
                                  unsigned int *pChecksum,
                                  unsigned char bPrintHexFile);
                                  
unsigned int OmnimaAPIReadFromSSD(const termioType *pio, 
                                  unsigned int startAddr,
                                  unsigned int len);

unsigned int OmnimaAPISendFileToSSD(const termioType *pio, 
                           const char *fileToUpload,
                           int startAddr,
                           int inclCheck);

unsigned int OmnimaAPIProgramFlash(const termioType *pio, const char *fileToUpload);

unsigned int OmnimaAPIStreamMJPEG(const termioType *pio, 
                                  const char *fileToUpload);

unsigned int OmnimaAPITestPort(const char *port, const char *baud);

unsigned int OmnimaAPIEnterISP(const termioType *pio, unsigned char bReboot);

unsigned int OmnimaAPITestPort(const char *port, const char *baud);

unsigned int DetectOLCDComPort(char **ppport, char **ppbaud);

typedef enum
{
  WIN_MAINPANEL=0,
  WIN_SUBPANEL,
  WIN_MAINSUBPANEL,
  WIN_FLOATING,
  WIN_CURSOR1,
  WIN_CURSOR2,
  WIN_MAX,
} WINDOWTYPE;

unsigned int OmnimaAPILine(const termioType *pio, 
                           WINDOWTYPE dstWin,
                           unsigned int x1, unsigned int y1,
                           unsigned int x2, unsigned int y2);

extern const char *g_WindowStrType[WIN_MAX];

unsigned int OmnimaAPIBitBlt(const termioType *pio, 
                             WINDOWTYPE srcWin,
                             unsigned int x1, unsigned int y1,
                             unsigned int w1, unsigned int h1,
                             WINDOWTYPE dstWin,
                             unsigned int x2, unsigned int y2,
                             unsigned int w2, unsigned int h2);

typedef enum 
{
    NONE=0,
    VFLIP=0x10,
    HFLIP=0x40,
    VHFLIP=0x50,
    HFLIP_ROT90=0xa0,
    ROT90=0xb0,
    ROT270=0xe0,
    HFLIP_ROT270=0xf0,
    TRANSPARENT_BLT=0x01
} ROTATETYPE;
                                                          
unsigned int OmnimaAPITextOut(const termioType *pio, 
                             WINDOWTYPE dstWin,
                             ROTATETYPE r,
                             unsigned int x, unsigned int y,
                             const char *str);               
#endif